package com.fz.song.feibao.framework.common.enums;

/**
 * 状态枚举
 */
public enum CodeEnum {

    OK(0, "ok"),
    TEST(-1, "test"),
    ERROR(1000, "error"),

    PARAM_ERROR(1001, "参数异常"),


    //所有未登录都返回这错误,前端检测到这个端口和
    NOT_LOGIN_ERROR(1100, "账号未登录"),

    USER_ABNORMAL(1101, "账号异常"),
    USERNAME_OR_PWD_ERROR(1102, "用户名或者密码错误"),
    USER_IS_LOCK(1103, "用户被锁定"),

    VERIFY_ERROR(1200, "验证码错误"),
    GET_VERIFY_CODE_TOO_MUCH(1201, "请求过于频繁,请稍后再试!"),

    USER_IS_EXIST(1300, "用户名已经存在"),
    MOBILE_IS_EXIST(1301, "手机号已经存在"),
    NICKNAME_IS_EXIST(1302, "昵称已经存在"),
    ;

    private int code;

    private String msg;

    private CodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static CodeEnum getEnum(int code) {
        CodeEnum[] values = CodeEnum.values();
        for (CodeEnum codeEnum : values) {
            if (codeEnum.getCode() == code) {
                return codeEnum;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
